package com.purong.purong.widget;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.purong.purong.R;


/**
 * Created by Administrator on 2016/8/8.
 */
public class LoadingDialog extends Dialog {
    private Context mContext;
    private  AnimationDrawable anim ;
    public LoadingDialog(Context context) {
        super(context, R.style.DialogTransparent);
        this.mContext=context;
        setCanceledOnTouchOutside(false);
        setCancelable(false);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        View inflate = LayoutInflater.from(mContext).inflate(R.layout.dialog_loading, null);
        setContentView(inflate);
        ImageView image=(ImageView)inflate.findViewById(R.id.load_img);
        image.setBackgroundResource(R.drawable.loading_dialog);
        anim = (AnimationDrawable) image.getBackground();
        anim.start();

    }

    @Override
    public void dismiss() {
        super.dismiss();
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (anim!=null){
            anim.stop();
            anim=null;
        }
    }
}
